home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 3 / Gold Medal Software - Volume 3 (Gold Medal) (1994).iso / prog / dnalib59.arj / EXTABS.BAS < prev    next >
BASIC Source File  |  1993-12-28  |  2KB  |  49 lines

  1. SUB ExpandTabs(Msg$)PUBLIC
  2.  
  3. CrLf$ = CHR$(13) + CHR$(10)
  4.  
  5. Msg$ = REMOVE$(msg$,CHR$(10))        'Temporary remove line feeds from
  6. Temp$ = ""                           'string. Leave C/R's for INSTR.
  7.  
  8. DO                                   'Set the master loop
  9.   IF Msg$ = "" THEN EXIT LOOP        'If no more string to process,
  10.                                      'perform a grand exit
  11.   EndOfLine% = INSTR(Msg$,CHR$(13))  'Find a C/R in the string.
  12.   IF EndOfLine% = 0 THEN             'If no C/R in string, reassign entire
  13.     Te$ = Msg$                       'remaining string to be processed
  14.     Msg$ = ""                        'and null out the main string
  15.   ELSE
  16.     Te$ = LEFT$(Msg$,EndOfLine%)     'Other wise, strip off the left hand
  17.     Tm$ = RIGHT$(Msg$,LEN(Msg$) - EndOfLine%) 'portion of the string for processing
  18.     Msg$ = Tm$                        'and rid it from the main string.
  19.     Tm$ = ""
  20.   END IF
  21.  
  22.   Te$ = REMOVE$(Te$,CHR$(13))          'Remove the C/R from string.
  23.  
  24.   DO
  25.     T1$ = "": T2$ = ""
  26.     TabPointer% = INSTR(Te$,CHR$(9))    'Find a TAB in the sub-string
  27.     IF TabPointer% = 0 THEN EXIT LOOP   'If none present, whole line done.
  28.       T1$ = LEFT$(Te$,TabPointer% - 1)  'Split the process string into 2
  29.       T2$ = RIGHT$(Te$,LEN(Te$) - TabPointer%) 'sub-strings with TAB as delimiter.
  30.                                         'NOTE: (p) points to the TAB character
  31.                                         'in t1$ so use p-1 to avoid it.
  32.       T1$ = T1$ + " "                   'Add a space to replace the lost TAB
  33.  
  34.       DO UNTIL LEN(T1$) / 8 = INT(LEN(T1$) / 8) 'Lengthen to a multiple of 8
  35.         T1$ = T1$ + " "
  36.       LOOP
  37.  
  38.     Te$ = T1$ + T2$                     'Concanotate original string with the
  39.   LOOP                                  'added spaces & loop for more TAB's
  40.   Temp$ = Temp$ + Te$ + CrLf$           'Build temporary holding string
  41. LOOP                                    'and loop back for next line.
  42. Msg$ = Temp$                            'Reassign the temporary hold string to
  43.                                         'the string being called
  44. Temp$ = ""                              'and null out temp strings for memory
  45. T1$ = ""                                'management.
  46. T2$ = ""
  47. Te$ = ""                                'finished
  48.  
  49. END SUB